package saas.dev.clouduserprovide.function;

import cn.hutool.core.bean.BeanUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import saas.dev.clouduserprovide.dto.UserDto;
import saas.dev.clouduserprovide.entity.User;

import java.util.function.Function;

/**
 * @author : y1
 * @className : UserMapperFunction
 * @date: 2023/3/10 18:06
 * @description :
 */
@Component
@AllArgsConstructor
public class UserDtoMapperFunction implements Function<User, UserDto> {

//    private final DeptService service;
    /**
     * Applies this function to the given argument.
     *
     * @param user the function argument
     * @return the function result
     */
    @Override
    public UserDto apply(User user) {
        UserDto userDto = BeanUtil.toBean(user, UserDto.class);
        userDto.setDeptName("测试");
//        userDto.setDeptName(service.getDeptName(userDto.getDeptId()));
        return userDto;
    }
}
